<template>
  <div class="add-topic-container">
    <div class="form-title">课题详情</div>
    <form class="topic-form" @submit.prevent="handleSubmit">
      <div class="form-group">
        <label>课题名称：</label>
        <input v-model="form.title" type="text" required />
      </div>
      <div class="form-group">
        <label>所属专业：</label>
        <select v-model="form.major" required>
          <option value="">--请选择--</option>
          <option value="计算机科学">计算机科学</option>
          <option value="软件工程">软件工程</option>
          <option value="信息安全">信息安全</option>
          <option value="其他">其他</option>
        </select>
      </div>
      <div class="form-group radio-group">
        <label>课题来源：</label>
        <div class="radio-options">
          <label><input type="radio" value="教师科研" v-model="form.source" /> 教师科研</label>
          <label><input type="radio" value="社会生产实践" v-model="form.source" /> 社会生产实践</label>
          <label><input type="radio" value="教学" v-model="form.source" /> 教学</label>
          <label><input type="radio" value="其他" v-model="form.source" /> 其他</label>
        </div>
      </div>
      <div class="form-group radio-group">
        <label>课题类型：</label>
        <div class="radio-options">
          <label><input type="radio" value="工程设计类" v-model="form.type" /> 工程设计类</label>
          <label><input type="radio" value="理论研究类" v-model="form.type" /> 理论研究类</label>
          <label><input type="radio" value="应用(试验)研究类" v-model="form.type" /> 应用(试验)研究类</label>
          <label><input type="radio" value="软件设计类" v-model="form.type" /> 软件设计类</label>
          <label><input type="radio" value="其他" v-model="form.type" /> 其他</label>
        </div>
      </div>
      <div class="form-group">
        <label>课题描述：</label>
        <textarea v-model="form.description" rows="5" required></textarea>
      </div>
      <div class="form-group">
        <label>指导教师：</label>
        <input type="text" v-model="form.teacher" />
      </div>
      <div class="form-actions">
        <button type="submit">提交申请</button>
        <button type="button" @click="handleClose">关闭</button>
      </div>
    </form>
  </div>
</template>

<script>
export default {
  name: 'AddTopic',
  data() {
    return {
      form: {
        title: '',
        major: '',
        source: '',
        type: '',
        description: '',
        teacher: ''
      }
    }
  },
  methods: {
    handleSubmit() {
      // 这里可以添加表单提交逻辑
      alert('提交成功！');
    },
    handleClose() {
      // 这里可以添加关闭逻辑，比如返回上一页
      this.$router.back && this.$router.back();
    }
  }
}
</script>

<style scoped>
.add-topic-container {
  width: 900px;
  margin: 16px auto 24px auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 40px 36px 40px 36px;
  min-height: 95vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.form-title {
  font-size: 30px;
  font-weight: bold;
  margin-top: 0;
  margin-bottom: 24px;
  color: #34495e;
}
.topic-form {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.topic-form .form-group {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
}
.form-group label {
  width: 200px;
  min-width: 200px;
  color: #222;
  font-size: 20px;
  font-family: inherit;
  font-weight: 500;
  margin-right: 8px;
  line-height: 40px;
  text-align: right;
}
.form-group > *:not(label) {
  flex: 1;
}
.topic-form input[type="text"],
.topic-form select,
.topic-form textarea {
  padding: 12px 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 18px;
  height: 48px;
  box-sizing: border-box;
}
.topic-form textarea {
  /* resize: vertical; */
  resize: none;
  min-height: 180px;
  height: auto;
}
.form-actions {
  text-align: right;
  margin-top: 2px;
  min-height: 72px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 0;
}
.form-actions button {
  background: #20bfa3;
  color: #fff;
  border: none;
  padding: 8px 22px;
  border-radius: 4px;
  font-size: 20px;
  margin-left: 6px;
  cursor: pointer;
}
.form-actions button[type="button"] {
  background: #e0e0e0;
  color: #333;
}
.topic-form .form-group.radio-group label {
  font-size: 18px;
  margin-right: 24px;
}
.topic-form .form-group.radio-group input[type="radio"] {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 6px;
}
/* 单独设置课题来源和课题类型的label字体大小 */
.topic-form .radio-group > label:first-child {
  font-size: 20px;
  font-weight: 500;
}
.radio-group {
  display: flex;
  align-items: center;
}
.radio-options {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 0;
  align-items: center;
}
.radio-options label {
  min-width: 160px;
  margin-right: 0;
  font-size: 18px;
  font-weight: 400;
  display: flex;
  align-items: center;
}
.radio-options input[type="radio"] {
  width: 18px;
  height: 18px;
  margin-right: 6px;
  vertical-align: middle;
}
</style>
